/* eslint-disable */
import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import Home from '../components/Home.vue'
import Welcome from '../components/Welcome.vue'
import Approved from '../components/history/Approved.vue'
import History from '../components/history/History.vue'
import NotApproved from '../components/history/NotApproved.vue'
import Approving from '../components/history/Approving'
import Book from '../components/book/Book.vue'
import CancelBook from '../components/book/CancelBook.vue'
import myInformation from '../components/my/myInformation.vue'
import myAccount from '../components/my/myAccount.vue'
import test from '../components/test.vue'
import sign from '../components/sign.vue'
import TodayMeeting from '../components/history/TodayMeeting.vue'
import HistoryApply from '../components/history/HistoryApply.vue'
Vue.use(VueRouter)

const routes = [{
		path: '/',
		redirect: '/login'
	},
	{
		path: '/login',
		component: Login
	},
	{
		path: '/sign',
		name:sign,
		component: sign
	},

	{
		path: '/test',
		component: test
	},
	{
		path: '/home',
		component: Home,
		redirect: '/book',
		children: [{
				path: '/Welcome',
				component: Welcome
			},
			{
				path: '/approved',
				component: Approved
			},
			{
				path: '/history',
				component: History
			},
			{
				path: '/notApproved',
				component: NotApproved
			},
			{
				path: '/approving',
				component: Approving
			},
			{
				path: '/book',
				component: Book
			},
			{
				path: '/cancelBook',
				component: CancelBook
			},
			{
				path: '/myInformation',
				component: myInformation
			},
			{
				path: '/myAccount',
				component: myAccount
			},
			{
				path: '/TodayMeeting',
				component:TodayMeeting
			},
			{
				path:'/HistoryApply',
				component:HistoryApply
			}

		]
	}
]

const router = new VueRouter({
	routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push=function push(localtion){
    return originalPush.call(this,localtion).catch(err=>err)
}
// 挂载路由导航守卫
/* router.beforeEach((to, from, next) => {
  // to 表示将要访问的路径
  // from 表示从哪个路径跳转而来
  // next 是一个函数，表示放行
  // next() 直接放行 next('/login') 强制跳转
  if (to.path === '/login') return next()
  // 获取token
  const tokenStr = window.sessionStorage.getItem('token')
  if (!tokenStr) return next('/login')
  next()
}) */

export default router
